package com.shuaigef.springbootinit.controller;

import com.shuaigef.springbootinit.common.BaseResponse;
import com.shuaigef.springbootinit.common.ResultUtils;
import com.shuaigef.springbootinit.service.FileService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequiredArgsConstructor
public class OssController {
    private final FileService fileService;

    @RequestMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public BaseResponse<String> upload(@RequestPart("file") MultipartFile file) {
        System.out.println(file);
        return fileService.uploadFile(file);
    }
}
